﻿using KayakMes.Common.Dtos.ProductControlDTO.Input;
using KayakMes.Common.Result;
using KayakMes.ProductControl.Application.Services;
using KayakMes.ProductControl.Domain.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace KayakMes.ProductControl.API.Controllers
{
    /// <summary>
    /// 产品管理—颜色管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ColourController : ControllerBase
    {
        private readonly IProductService productService;
        /// <summary>
        /// 通过构造函数注入颜色服务
        /// </summary>
        /// <param name="productService"></param>
        public ColourController(IProductService productService)
        {
            this.productService = productService;
        }
        /// <summary>
        /// 添加颜色信息
        /// </summary>
        /// <param name="colour">颜色模型</param>
        /// <returns>返回受影响行数</returns>
        [HttpPost]
        public ApiResult<int> AddColour(ColourModel colour)
        {
            return productService.AddColour(colour);
        }
        /// <summary>
        /// 获取所有颜色信息
        /// </summary>
        [HttpGet]
        public ApiPaging<ColourModel> GetAllColour(ColourDto dto)
        {
            return productService.GetAllColour(dto);
        }
        /// <summary>
        /// 通过Id获取颜色信息
        /// </summary>
        /// <param name="Id">颜色ID</param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<ColourModel> GetColour(long Id)
        {
            return productService.GetColour(Id);
        }
        /// <summary>
        /// 更新颜色信息
        /// </summary>
        /// <param name="colour">颜色模型</param>
        /// <returns>返回受影响行数</returns>
        [HttpPut]
        public ApiResult<int> UpdateColour(ColourModel colour)
        {
            return productService.UpdateColour(colour);
        }
        /// <summary>
        /// 删除颜色信息
        /// </summary>
        /// <param name="Id">颜色实体Id</param>
        /// <returns>返回受影响行数</returns>
        [HttpDelete]
        public ApiResult<int> DelColour(long Id)
        {
           return productService.DelColour(Id);
        }
    }
}
